package org.arch_learn.elastic_search.springboot_es.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 使用jdbc是因为jdbc底层批处理性能更好
 */
public class DBHelper {
    public static final String url = "jdbc:mysql://127.0.0.1:3306/elastic_search_demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai";
    public static final String name = "com.mysql.jdbc.Driver";
    public static final String user = "root";
    public static final String password = "123456";
    public static Connection conn = null;

    public static Connection getConn() {
        try {
            Class.forName(name);
            conn = DriverManager.getConnection(url, user, password);
            //获取连接
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }

    public static void releaseConn() throws SQLException {
        conn.close();
    }
}

